home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 11
/
Cream of the Crop 11-1.iso
/
utility
/
pwg_key.zip
/
KRS100.ZIP
/
KRS.WCC
< prev
next >
Wrap
Text File
|
1995-05-18
|
4KB
|
123 lines
' Function KeyRegistration System (KRS)
' by Mark Schwandt & William Mantz
' for wcCODE programs.
'
' This Code is hereby released to the Public Domain.
'
' Usage:
'
' INT Registered = KRS(RegNumber as LONG, ProgId as Long)
'
' returns FALSE (0) if RegNumber doesn't Match KRS calculation
' with supplied Program ID. NOTE: Program ID is what you
' pick when compiling your KeyMaker program. It is an integer
' number from (1-99999). Your Program MUST pass the
' RegNumber from your Program's CFG file, along with your
' Program ID number (hard coded) in your program.
'
' Example:
'
' Your Program reads a .CFG file and gets the Registration Number
' 231909210 as variable RegNumber (that Sysop is using).
' You would then call the KRS() Function to determine if
' this number is correct. You have picked 12300 as your Custom
' program ID number for this program. It can be any number from
' 1 to 99999). Here is the code....
'
' DIM RegNumber as LONG
' DIM Registered as INTEGER
'
' Registered = FALSE
'
' OPEN cfgFile for INPUT AS #1
' INPUT #1, RegNumber
' CLOSE #1
'
' IF KRS(RegNumber, 12300) THEN
' REGISTERED = TRUE
' ELSE
' REGISTERED = FALSE
' END IF
'
' The 12300 number in the KRS() function is the Number you picked
' as your Custom Program ID number. It can be any number 1-99999).
'
'-----------------------------------------------------------------------
' Algorith Used: (based on PRIME Number 7 and Your Custom ProgID)
' Wildcat! BBS Name is calculated into a CheckSum (All upper case).
' and added to the Wildcat! BBS Reg. ID Number CheckSum.
' The Combined CheckSum is then Multiplied to the Specific Custom
' Program ID number that the programmer uses for his Program.
' This total is then added to the Program ID number leaving a
' Resulted LONG Integer Number used for the Key.
' ChkSum(BBSName) + ChkSum(BBSRegNum) * 7 * ProgID + ProgID = Key as LONG
'-----------------------------------------------------------------------
'
' To use, Put '$ INCLUDE "KRS.WCC" in your Program at the Top which
' will include this function in the compilation. The KRS.WCC
' MUST be located in the same directory when you compile.
'
'
'
'DECLARE FUNCTION KRS(RegNumber AS LONG, ProgId as LONG) AS INTEGER
FUNCTION KRS( RegNumber as LONG, ProgId as LONG) AS Integer
Dim Expand as Integer
Dim StrChkSum as Long
Dim ProgChkSum AS LONG
Dim BBSName as STRING*30
Dim BBSstrID as STRING*7
DIM BBSId as LONG
' first, Get the BBS Name from MakeWild's Record information.
' Trim it and make it all UPPER CASE, then Get the CheckSum of it.
BBSName = UCASE(MakeWild.BBSname)
BBSName = TRIM(BBSName)
StrChkSum = 0
For Expand = 1 to Len(BBSName)
StrChkSum = StrChkSum + Asc(Mid(BBSName,Expand,1))
Next Expand
' StrChkSum has the CheckSum of the BBS name.
' Next, Get the BBS Reg Number from MakeWild's record Information.
' and Get the ChkSum of it.... ProgChkSum contains the iD.
BBSstrID = UCASE(MakeWild.RegString)
BBSstrID = TRIM(BBSstrID)
ProgChkSum = 0
For Expand = 1 to Len(BBSstrID)
ProgChkSum = ProgChkSum + Asc(Mid(BBSstrID,Expand,1))
Next Expand
' Add the BBSName CheckSum and the BBS ID checkSum together.
ProgChkSum = ProgChkSum + StrChkSum
' Multiply the CheckSum by the Prime Number 7
ProgChkSum = ProgChkSum * 7
' Multiply the ProgChkSum by the Program's custom ID number.
ProgChkSum = ProgChkSum * ProgId
' Add the Calculated CheckSum by Program's Custom ID Number.
ProgChkSum = ProgChkSum + ProgId
' -------------------------------------------------------------
' Calculations are complete! Now do the compare with
' what was inputed to the function.
'
IF ProgChkSum = RegNumber THEN
KRS = -1
ELSE
KRS = 0
END IF
END FUNCTION